﻿using System;
using System.Collections.Generic;
using System.Text;
using TSVNAddin.SVN;
using EnvDTE;

namespace TSVNAddin.Core
{
	public class ItemActionExecutor : IItemEventListener
	{
		private readonly PathAddedAction _AddedAction;
		private readonly PathRemovedAction _RemovedAction;
		private readonly PathRenamedAction _RenamedAction;

		public ItemActionExecutor(PathAddedAction addedAction, PathRemovedAction removedAction, PathRenamedAction renamedAction)
		{
			_AddedAction = addedAction;
			_RemovedAction = removedAction;
			_RenamedAction = renamedAction;
		}

		public void NotifyAdded(ProjectItem projectItem)
		{
			string path = projectItem.get_FileNames(0);

			//new PathAddedAction(_VersionControl, new FileSystemAdapter())
			//    .NotifyAdded(path);

			_AddedAction.Execute(path);
		}

		public void NotifyRemoved(ProjectItem projectItem)
		{
			string path = projectItem.get_FileNames(0);

			//new PathRemovedAction(_VersionControl)
			//    .NotifyRemoved(path);

			_RemovedAction.Execute(path);
		}

		public void NotifyRenamed(ProjectItem projectItem, string oldName)
		{
			string toPath = projectItem.get_FileNames(0);

			//new PathRenamedAction(_VersionControl, new FileSystemAdapter())
			//    .NotifyRenamed(toPath, oldName);

			_RenamedAction.Execute(toPath, oldName);
		}
	}
}
